<template>
  <div class="category">
    <router-link :to="`/product/${good.id}`">
      <div class="top">
        <img v-lazy="good.picture"/>
        <div class="ellipsis-2">{{ good.name }}</div>
      </div>
      <div class="bottom">
        <div class="ellipsis">{{ good.desc }}</div>
        <div>￥{{ good.price }}</div>
      </div>
    </router-link>
    <router-link :to="`/category/${cateId}`"
                 class="cover">
      <div>找相似</div>
      <div>发现更多宝贝 ></div>
    </router-link>
  </div>
</template>

<script lang="ts"
        setup>
import type {Good} from '@/types/good'
import {toRefs} from 'vue'

let props = defineProps<{
  data: Good,
  cateId: string
}>()
let {data: good, cateId} = toRefs(props)
</script>

<style lang="less"
       scoped>
.category {
  width: 240px;
  height: 300px;
  border: 1px solid white;
  padding: 10px 40px;
  position: relative;
  overflow: hidden;

  &:hover {
    border-color: @xtxColor;

    .cover {
      bottom: 0;
    }
  }

  .top {
    height: 210px;

    img {
      height: 160px;
      width: 160px;
    }

    div {
      padding-top: 4px;
      font-size: 16px;
      height: 50px;
    }
  }

  .bottom {
    height: 68px;

    div:nth-of-type(1) {
      font-size: 16px;
      margin-top: 6px;
    }

    div:nth-of-type(2) {
      color: @priceColor;
      margin-top: 10px;
      font-size: 20px;
    }
  }

  .cover {
    transition: all 1s;
    position: absolute;
    left: 0;
    bottom: -78px;
    width: 100%;
    height: 78px;
    background-color: @xtxColor;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;

    div:nth-of-type(1) {
      font-size: 18px;
      width: 120px;
      border-bottom: 1px solid white;
      line-height: 40px;
      margin-top: 5px;
    }

    div:nth-of-type(2) {
      line-height: 30px;
    }
  }
}
</style>